import axios from 'axios'

const api = axios.create({
  baseURL: '/api',
  timeout: 5000
})

export interface LoginData {
  username: string
  password: string
}

export interface RegisterData extends LoginData {
  email: string
}

export interface UserInfo {
  id: number
  username: string
  email: string
  avatar: string
  role: string
}

export const userApi = {
  login(data: LoginData) {
    return api.post('/login', data)
  },

  register(data: RegisterData) {
    return api.post('/register', data)
  },

  getUserInfo(id: number) {
    return api.get(`/user/${id}`)
  }
} 